package com.dolphin.common.component.var.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author shida
 */
@Getter
public enum FiledTypeEnum {
    STRING("string","字符串"),
    INTEGER("integer","整型"),
    LONG("long","长整型"),
    BIG_DECIMAL("bigDecimal","bigDecimal"),
    FLOAT("float","浮点型"),
    DOUBLE("double","双精度"),
    BOOLEAN("boolean","布尔型"),
    DATE("date","日期型")
    ;

    private String type;
    private String description;

    FiledTypeEnum(String type, String description) {
        this.type = type;
        this.description = description;
    }

    public static FiledTypeEnum getByType(String type){
        if(StringUtils.isEmpty(type)){
            throw new RuntimeException("FiledTypeEnum is empty:" + type);
        }

        for(FiledTypeEnum item : values()){
            if(item.name().equals(type)){
                return item;
            }
        }

        throw new RuntimeException("Unsupported FiledTypeEnum:" + type);
    }


}
